class Backend::CategoriesController < Backend::ApplicationController
  def index
    @categories = Category.all.order('id DESC')
    @category = Category.new
  end

  def create
    @category = Category.new category_params
    @category.save
  end

  def edit
    @categories = Category.all.order('id DESC')
    @category = Category.find params[:id]
    render :index
  end

  def update
    @category = Category.find params[:id]
    @category.update category_params
  end

  def destroy
    @category = Category.find params[:id]
    @category.destroy
  end

  private
  def category_params
    params.require(:category).permit(:name)
  end
end
